package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mycache.annotation.CacheUsing;
import com.qf.dao.GoodsDao;
import com.qf.entity.Goods;
import com.qf.service.GoodsService;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * (Goods)表服务实现类
 *
 * @author makejava
 * @since 2020-12-04 09:43:14
 */
@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements GoodsService {

    @Override
//    @CacheUsing(key = "'goods_time_' + #time")
    public List<Goods> queryByTime(String time) {
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>().eq("begin_time", time);
        return super.list(queryWrapper);
    }

    @Override
//    @CacheDel(key = "'goods_time_' + #entity.beginTime")
    public boolean save(Goods entity) {
        //将商品库存信息 同步到redis中
        return super.save(entity);
    }

    @Override
    @CacheUsing(key = "'goods_details_' + #id")
    public Goods getById(Serializable id) {
        return super.getById(id);
    }
}